//
// Created by 崔世强 on 2018/4/2.
// Copyright (c) 2018 Facebook. All rights reserved.
//

import Foundation
import SwiftyJSON

class ChangeMemberRoleHandler: NoticeHandlerProtocol {
    static let instance = ChangeMemberRoleHandler()

    private init() {
    }

    func handler(_ msg: Message) {

    }

    func show(_ msg: ChatMessage) -> String? {
        do {
            let contact = try ContactDao.getContact(msg.from)
            let groupMember = try GroupDao.getMember(msg.sessionId, userId: msg.from)

            let json = JSON(parseJSON: msg.text ?? "")

            var name = contact?.remarkName ?? groupMember?.nickName ?? contact?.name
            if msg.isMe {
                name = "你"
            }
            return "\(name ?? "管理员" ) 开启了全体禁言"

        } catch {
            return msg.text
        }
    }
}
